<html>
<head>
<meta charset="UTF-8">
<title>应用插件信息列表</title>
	<link id="easyuiTheme" href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
	<link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
	<script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.cookie.js" type="text/javascript"></script>
	<script src="../../static/easyui/ui-theme.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
	<script src="../../ffres/dict/all.js" type="text/javascript"></script>
	<link href="../../static/easyui/themes/frameless.css" rel="stylesheet" type="text/css"/>
	<a href="" target="_blank" id="commonLink" name="commonLink"></a>
<script type="text/javascript">

    var enname="01";
    $(function() {
        menuFuncOp($.getUrlParam('funcOpStr'));
    });

    //根据用户拥有的资源操作权限信息，动态控制按钮
    function menuFuncOp(funcOpStr) {
        if(null != funcOpStr && "" != funcOpStr){
            var linkButtons = document.getElementById("tb").getElementsByClassName("easyui-linkbutton");
            for(var i = 0; i < linkButtons.length; i++){
                if(funcOpStr.indexOf(linkButtons[i].id) == -1){
                    document.getElementById(linkButtons[i].id).style.display = 'none';
                }
            }
        }
    }

	function doAdd(){
		JLEUtil.createModalWin('新增', 'PluginDefineAdd.html?enname='+enname);
	}
	
	function doUpdate() {
		var row = $('#dg').datagrid('getSelected');
		if (row){
			JLEUtil.createModalWin('修改', 'PluginDefineUpdate.html?' + 'pluginId=' + row.pluginId);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	
	function doDelete(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			$.messager.confirm('删除提示', '你确定要删除这条记录?', function(r){
				if (r){
					var jsonData = JSON.parse('{'+'"pluginId":"' + row.pluginId + '"'+'}');
					$.restfulDelete('../../api/plugin/define', jsonData, function(data) {
						$.messager.alert('提示','记录删除成功!','info');
						$('#dg').datagrid('reload');
					});
				}
			});
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doView(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			JLEUtil.createModalWin('详情','PluginDefineView.html?' + '&pluginId=' + row.pluginId);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	
	function doPluginParam(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			if(row.pluginConfigUrl){
				JLEUtil.createModalWin('详情' , row.pluginConfigUrl + '?' + '&pluginId=' + row.pluginId);
			} else {
				$.messager.alert('提示','该插件无参数配置页面！','info');
			}
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

    //查询列表
    function queryList(id,pluginId){
        if (pluginId==""){
            $('#dg').datagrid({
                queryParams: {
                    pluginCatalog: id,
                }
            });
        }else {
            $('#dg').datagrid({
                queryParams: {
                    pluginCatalog: id,
                    pluginId:pluginId
                }
            });
        }
        $("#dg").datagrid({url:'../../api/plugin/defines'})
    }
    //获取字典项生成树菜单
    function getDic() {
        jsonData={
            opttype:"BAT_PLUGIN_CATALOG"
        }
        $.restfulPostForm("../../api/s/dics",jsonData,function (data) {
            var  treeData="";
            treeData+="[{"
            console.log(data.rows.length)
            for (var i=0;i<data.rows.length;i++) {

                if (i==0){
                    treeData+='"id":"'+data.rows[i].enname+'","text":"'+data.rows[i].cnname+'"}'
                } else {
                    treeData+=',{"id":"'+data.rows[i].enname+'","text":"'+data.rows[i].cnname+'"}'
                }
            }
            treeData+="]"
            //转为json
            treeData =eval("(" + treeData + ")");
            $('#menu_app1').tree({
                data: treeData
            });
        })
    }
    $(function () {
        getDic();
        queryList('01');
        $('#menu_app1').tree({
            onClick: function(node){
                queryList(node.id)
                enname =node.id
            }
        });
    })

	function reloadList(){
		$('#dg').datagrid('reload');
		JLEUtil.closewin();
	};	
</script>
</head>
<body class="easyui-layout">
<div id="1" data-options="region:'west',title:'插件分类',split:true" style="width: 220px;">
	<div>
		<ul class="easyui-tree" formatter="formatter_BAT_PLUGIN_CATALOG" data-options="animate:true,lines:true"
			id="menu_app1">
		</ul>
	</div>
</div>
<div data-options="region:'center',split:false">
	<div data-options="region:'north',title:''" style="height: 40px;">
		<form id="searchForm">
			<table>
				<tr>
					<td>&nbsp;应用插件ID：</td>
					<td><input name="pluginId" id="pluginId"/></td>
					<td><a class="easyui-linkbutton" href="javascript:void(0);" onclick=queryList(enname,$('#pluginId').val())>查找</a></td>
					<td><a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.clearForm('searchForm');">清空</a></td>
				</tr>
			</table>
		</form>
	</div>
<table id="dg" class="easyui-datagrid" title="" style="width:100%;height:90%"
			data-options="singleSelect:true,collapsible:true,url:'../../api/plugin/defines',method:'post'"
			toolbar="#tb"
		title="Load Data" 
		rownumbers="true" pagination="true" pageSize="20">
		<thead>
			<tr>
				<th data-options="field:'pluginId',resizable:true" width="10%">应用插件ID</th>
				<th data-options="field:'pluginName',resizable:true" width="16%">应用插件名称</th>
				<th data-options="field:'pluginClass',resizable:true" width="38%">应用插件实现类</th>
				<th data-options="field:'pluginConfigUrl',resizable:true" width="20%">应用插件配置地址</th>
				<!--<th data-options="field:'pluginCatalog',resizable:true" formatter="formatter_BAT_PLUGIN_CATALOG" width="20%">应用插件分类</th>-->
								<th data-options="field:'needOtherDsVar',resizable:true" width="16%">需要其它数据源变量</th>				
				<th data-options="field:'pluginDesc',resizable:true" width="20%">应用插件描述</th>

			</tr>
		</thead>
	</table>
</div>
<div id="tb" style="padding:1px">
	<div style="margin-bottom:2px">
		<a href="javascript:doAdd()" class="easyui-linkbutton" iconCls="icon-add" plain="true" id="create">新增</a>
		<a href="javascript:doUpdate()" class="easyui-linkbutton" iconCls="icon-edit" plain="true" id="modify">修改</a>
		<a href="javascript:doDelete()" class="easyui-linkbutton" iconCls="icon-remove" plain="true" id="delete">删除</a>
		<a href="javascript:doView()" class="easyui-linkbutton" iconCls="icon-ok" plain="true" id="detail">查看</a>
		<a href="javascript:doPluginParam()" class="easyui-linkbutton" iconCls="icon-ok" plain="true" id="config">插件参数</a>
	</div>
</div>
</body>
</html>
